﻿

  /*初始化*/
layui.use(['layer', 'table', 'element', 'laydate', 'form', 'tree'], function(){
	/*UI插件加载*/
  window.layLayer = layui.layer;
  window.layTable = layui.table;
  window.layElement = layui.element;
  window.layDate = layui.laydate;
  window.layForm = layui.form;
  window.layTree = layui.tree;

  /*初始化用户信息*/
  if(!localStorage.userInfo || localStorage.userInfo == "undefined"){
    window.location.href = "login.html";
    return;
  }
  var userinfo = JSON.parse(localStorage.userInfo);
  if(userinfo == null){
    window.location.href = "login.html";
    return;
  }

  /*存储areaCode*/
    window.localStorage.setItem("areaCode", userinfo.code);
    Global.currentAreaCode = userinfo.code;
    Global.currentCrop = userinfo.type;
    Global.currentAreaName = userinfo.cn;
  /*获取导航和查询组件*/
  getNav();

  /*初始化dom事件*/
  initDom();

  /*自定义站初始化*/
  customizeStation.init(userinfo.code);

  /*项目展示和执行方式*/
  switch ( Config.DISPLAY_TYPE ) {
    /*展示图片*/
    case 'ONLY_IMAGE':
      $('.content-nav .map-nav').text('图片');
      $('#gisGraphics').find('select[name="displayType"]').prop('disabled', true);
      break;
    /*展示地图*/
    case 'ONLY_MAP':
      map.init();
      $('#gisGraphics').find('select[name="displayType"]').prop('disabled', false);
      break;
  }

  /*统计图初始化*/
  chartPlay.init();

  /*模板选择行政区初始化*/
  countryArea.init(userinfo.code);

  /*省市县初始化*/
  area.init(userinfo.code);
  
  changeUI();



});

//根据作物和区域修改UI
function changeUI(){
  changeBanner();
  changeLogo();
  changeBg();
  changeTitle();
}


function initUser(){

}

function loginOut(){
  localStorage.clear();
   window.location.href = "login.html";
}

function changeBanner(){

   var crop =  Global.currentAreaCode == "610111"? "yingtao":Global.currentCrop;
    $("#nav").css("background","url(images/banner/bg_"+ crop +".png)");
}

function changeLogo(){
  var crop =  Global.currentAreaCode == "610111"? "fruit":Global.currentCrop;
  $("#logoimg").attr("src","images/logo/logo_"+ crop +".png");
}

function changeBg(){
  var crop =  Global.currentAreaCode == "610111"? "yingtao":Global.currentCrop;
  $("#resultBox").css("background","url(images/bg/bg_"+ crop  +".png) no-repeat right bottom");
}

function changeTitle(){
  $("#systitle").html(Global.currentAreaName);
}

//获取导航栏
function getNav(areaName){
  var path="",len = Global.currentAreaCode.length;
  var crop = Global.currentCrop;
  if(Global.currentAreaCode == "610111") crop = "fruit";
  if(len==2){
    path="xml/menu_province_"+ crop +".xml";
  }else if(len == 4){
    path="xml/menu_city_"+ crop +".xml";
  }else{
    path="xml/menu_county_"+ crop +".xml";
  }
 // alert(Global.currentAreaCode+"_"+Global.currentCrop);
	$.ajax({
		type : "get",
		url : path,
		dataType : "xml",
		// timeout : 1000,
		success : function(data) {

      /*三级菜单获取*/
      Global.navArray = $(data).find("nav").map(function () {
        var navArray = $(this).find("class").map(function () {
          var classArray = $(this).find("element").map(function () {
            return { name: $(this).attr("name"), url: $(this).attr("url"), icon: $(this).attr("icon"), type: $(this).attr("type") }
          });
          return { name: $(this).attr("name"), url: $(this).attr("url"), icon: $(this).attr("icon"), value: [].slice.call(classArray) }
        });
        return { name: $(this).attr("name"),icon:$(this).attr("icon"), value: [].slice.call(navArray) }
      });

      /*类数组dom对象转换为数组*/
      Global.navArray = [].slice.call(Global.navArray);

      /*加载菜单dom*/
      initNav();
    }
	});

}
//加载导航栏
function initNav(){
  var navHtml = Global.navArray.reduce(function (all, cur) {
    return all += '<li class="layui-nav-item navA" name="'+ cur.name +'"><a href="javascript:;"><i class="mainnav-icon"><img src="'+ cur.icon.toString() +'" /></i><div class="mainnav-title">'+ cur.name +'</div></a></li>';
  }, '');

  $("#navDiv").html(navHtml);
  $(".navA").find("a").click(function(){
    $(this).parent().siblings().css("background","#def6f7").find("a").css("color","#333");
    $(this).parent().css("background","#57c030").find("a").css("color","#fff");//#caf4de
  }).eq(0).parent().css("background","#57c030").find("a").css("color","#fff");
 

  /*动态加载后更新渲染*/
  layElement.render('nav', 'navDiv');

	$(".navA").click(function(){
    $(this).addClass('layui-this').siblings().removeClass('layui-this');
    var name = $(this).attr("name");
    initClass(name);
    $('#leftDiv').children('.left-title').text($(this).text());
	}).eq(0).trigger('click').addClass('layui-this');

}

//加载左侧菜单
function initClass(name){
	//二级菜单
	var classHtml = Global.navArray.filter(function (val) { return val.name === name })[0].value.reduce(function (menu, item) {
    var control = item.value.reduce(function (all, cur) {
      return all += '<dd class="elementA" name="'+ cur.name +'" type="'+ cur.type +'" url="'+ cur.url +'"><a href="javascript:;">'+ cur.name +'</a></dd>';
    }, '');
    return menu += '<li class="layui-nav-item classA" url="'+ item.url +'">' +
      '<a href="javascript:;"><i class="nav-icon"><img src="'+ item.icon +'" alt=""></i>'+ item.name +'</a>' +
      (control ? '<dl class="layui-nav-child">'+ control +'</dl>' : '')  +
    '</li>';
  }, '');


	$("#leftDiv").children('.left-content').html(classHtml);

  layElement.render('nav', 'leftContent');

  var category = $(".classA");
  category.click(function(){
	  /*没有子菜单，直接读取url*/
	  if ( String( $(this).attr("url") ) !== 'undefined' ) {
      initElement($(this).attr("url"),$(this).html());
    }
    $(this).siblings().removeClass('layui-nav-itemed');
   	}).eq(0).trigger('click');

  $(".elementA").click(function(){
    Global.currElementName = null;
    Global.ElementName = $(this).attr("name");
    Global.layName=$(".layui-nav-itemed").children()[0].innerText;
    let url = $(this).attr("url");
    $(".custom_farm").hide();
    $("#PeriodYearDiv").hide();
    if ( $(this).attr("type") === "undefined" ) {
      initElement( url, $(this).html() ); 
   if ( $(".layui-table-view") ){
	   $(".layui-table-view").remove()
   } 	  
      $("#middleDiv").show();
      $("#rightDiv").show();
    } else {
      $(".custom_farm").show();
   window.localStorage.setItem("cropName", $(this).attr("type"));
      $(".custom_farm > iframe").attr("src", url);
      $("#middleDiv").hide();
      $("#rightDiv").hide();
    }
  });

  /*第一个有子目录才触发*/
	if ( category.eq(0).find('.elementA').length ) {
    category.eq(0).addClass('layui-nav-itemed').find('.elementA:first').addClass('layui-this').trigger('click');
  } else {
    category.eq(0).addClass('layui-this');
  }


}
//请求面板
function initElement(url,name){
	clearElementObj();
	Global.elementArray=[];
	$.ajax({
		type : "get",
		// async : false,
		// cache : false,
		url : "xml/"+url,
		dataType : "xml",
		timeout : 1000,
		success : function(data) {
      resolveConfig(data);
		}
	});
}

/*解析菜单面板配置*/
function resolveConfig(data) {
   Global.currentElement = $(data).find("YaosuQueryRequestBusinissType").children().eq(1)[0].textContent;
   $(data).find("YaosuQueryRequestZhiBiao").each(function(i){
    var elementObj=createElementObj();
    $(this).find("Name").each(function(j){
      elementObj.name=$(this).text();
    });
    if(typeof(Global.currElementName) == "undefined"||Global.currElementName==null||Global.currElementName==""){
      Global.currElementName=elementObj.name;
    }
    $(this).find("IsGroupByDay").each(function(j){
      elementObj.isGroupByDay=$(this).text();
    });
    $(this).find("DayCalWays").each(function(j){
      elementObj.hasCalWays=true;
      $(this).find("CalWay").each(function(k){
        elementObj.calWayArray.push($(this).text());
      });
    });
    $(this).find("RequestTypes").each(function(j){
      $(this).find("YaosuQueryRequestAnalysisType").each(function(j){
        elementObj.requestTypeArray.push($(this).text());
      });
    });
    $(this).find("SpatialWays").each(function(j){
      $(this).find("SpatialWay").each(function(k){
        elementObj.spatialWayArray.push($(this).text());
      });
    });
    $(this).find("StationTypes").each(function(j){
      $(this).find("StationType").each(function(k){
        elementObj.stationTypeArray.push($(this).text());
      });
    });
    $(this).find("IsNccYearSetting").each(function(j){
      elementObj.isNccYearSetting=$(this).text();
    });
    $(this).find("IsDayTimeTypeSupportted").each(function(j){
        elementObj.isDayTimeTypeSupportted=$(this).text();
      });
    $(this).find("TimeTypes").each(function(j){
      $(this).find("TimeType").each(function(k){
        elementObj.timeTypeArray.push($(this).text());
      });
    });
    //$(this).find("SubZhiBiaoAppendixes").each(function(j){
    $($(this).children("SubZhiBiaoAppendixes")).find("string").each(function(k){
      elementObj.zhibiaoArray.push($(this).text());
    });

    //});
    //$(this).find("SubZhiBiaoAppendixesCaption").each(function(j){
    $($(this).children("SubZhiBiaoAppendixesCaption")).find("string").each(function(k){
      elementObj.zhibiaoCaptionArray.push($(this).text());
    });
    //});
    $(this).find("RequestFlag").each(function(j){
      elementObj.requestFlag=$(this).text();
    });
        //面板自定义名称
    $(this).find("PanelNames").each(function(j){
      $(this).find("zhibiaoName").each(function(j){
          elementObj.panelNames.zhibiaoName=$(this).text();
       });
    });
    //启用RenderPath add by heyao 
    $(this).find("GISParam").each(function(j){
      $(this).find("RenderPath").each(function(k){
        elementObj.GISParamRenderPath=$(this).text();
      });
    });

    /*指标设置*/
    /*指标类型， 数组形式，分阶段，每阶段根据需要配置范围*/
    $(this).find("cornGrade").each(function(){
      var stage = [].slice.call($(this).children('stage')).map(function (val) {
        var range = [].slice.call($(val).children('range')).map(function (ran) {
          return {name: $(ran).children('name').text(), value: $(ran).children('value').text().split(',')}
        });
        return {name: $(val).children('name').text(), range: range};
      });
      elementObj.indexSetting.push({
        name: $(this).children('name').text(),
        stage: stage
      });
    });
    
    if(Global.statisticConfig != null){
      if(Global.statisticConfig.StatisticElements == null 
        || Global.statisticConfig.StatisticElements == "undefined")
        Global.statisticConfig.StatisticElements = {};
      if(Global.statisticConfig.StatisticElements[elementObj.name] == "undefined" 
      || Global.statisticConfig.StatisticElements[elementObj.name] == null)
          Global.statisticConfig.StatisticElements[elementObj.name] = new Array();
    }
    $(this).find("StatisticConfig").find("StatisticElements").find("StatisticElement").each(function(){
      
      var ele,eleCode,eleName,timeScale,chartTheme;
      ele  = this;
      if($(ele).find("ElementCode") !=null)
       eleCode = $(ele).find("ElementCode").text();
       if($(ele).find("ElementName") !=null)
       eleName = $(ele).find("ElementName").text();
       if($(ele).find("TimeScale") !=null)
       timeScale = $(ele).find("TimeScale").text();
       if($(ele).find("ChartTheme") !=null)
       chartTheme = $(ele).find("ChartTheme").text();
       Global.statisticConfig.StatisticElements[elementObj.name].push({eleCode:eleCode,eleName:eleName,timeScale:timeScale,chartTheme:chartTheme});
    });

    Global.dataEnv = "Observe";
    $(this).find("IndexConfig").each(function(){
        var indextype = $(this).find("IndexType").text();
        var datatype = $(this).find("DataType").text();
        var cropcode =  $(this).find("CropCode").text();
        var regioncode = $(this).find("RegionCode").text();
        var outcolumn = $(this).find("OutColumn").text();
        var disastercode = $(this).find("DisasterCode").text();
        var curDate = new Date();
        var t = new Date(curDate.getTime() - 24*60*60*1000);
        var y = t.getFullYear(),m = t.getMonth()+1,d=t.getDate();
        
        if(datatype == null || datatype == "") datatype = "Observe";
        m = m<10 ? "0"+m:m; d= d<10 ? "0"+d : d;
        var forecasttime = y+""+m+""+d;
        var indexParams = "indextype="+ indextype +";datatype="+ datatype +";cropcode="+ cropcode +";regioncode="+ regioncode +";outcolumn="+ outcolumn;
        if(datatype == "Forecast"){
          indexParams+= ";forecasttime="+forecasttime;
          Global.dataEnv = "Forecast";
        }
        if(indextype == 2){
          indexParams += ";disastercode="+disastercode;
        }
        elementObj.indexConfig = indexParams;
    });


         /*指标设置 干热风*/
    /*指标类型， 数组形式，分阶段，每阶段根据需要配置范围*/
    $(this).find("dry").each(function(){
      var stage = [].slice.call($(this).children('stage')).map(function (val) {
        var range = [].slice.call($(val).children('range')).map(function (ran) {
          return {name: $(ran).children('name').text(), value: $(ran).children('value').text().split(',')}
        });
        return {name: $(val).children('name').text(), range: range};
      });
      elementObj.drySetting.push({
        name: $(this).children('name').text(),
        stage: stage
      });
    });

		/*空间类型*/
    $(this).find("RegionValueType").each(function(){
      elementObj.spaceType.push($(this).text());
    });

		/*阈值组件*/
    elementObj.thresholdRange = {
      min: $(this).find('DefaultLeftFilter').text(),
      max: $(this).find('DefaultRightFilter').text(),
      selected: $(this).find('IsLiangFilter').length,
      maxType: $(this).find('DefaultRightOper').text(),
      minType: $(this).find('DefaultLeftOper').text()
    };

		/*历史统计*/
    $(this).find('StatisticWays').children('StatisticWay').each(function () {
      elementObj.historyStatic.push($(this).text());
    });
    
    $(this).find("isNotTable").each(function(j){
        elementObj.isNotTable=$(this).text();
    });
    $(this).find("dapServerName").each(function(j){
        elementObj.dapServerName=$(this).text();
    });
    /**干旱类型 */
    $(this).find("Droughs").each(function(j){
      $(this).find("Drough").each(function(k){
        elementObj.Droughs.push($(this).text());
      });
    });
       /**土壤层次平均 */
       $(this).find("HumidityAvgs").each(function(j){
           $(this).find("Avg").each(function(k){
               elementObj.HumidityAvgs.push($(this).text());
           });
       });
       /**土壤类型 */
       $(this).find("HumidityTypes").each(function(j){
           $(this).find("HumidityType").each(function(k){
               elementObj.HumidityTypes.push($(this).text());
           });
       });
	          /* 生产类作物类型*/
       $(this).find("CropTypes").each(function(j){
           $(this).find("CropType").each(function(k){
               elementObj.CropTypes.push($(this).text());
           });
       });

		/*添加全局变量要素配置*/
    Global.elementArray.push(elementObj);
  });

  /*加载面板*/
  initControlByName(Global.currElementName);


  /*面板加载完成后，初始化颜色图例*/
  colorSelect.init();

}

//根据指标名获取图例路径 add by heyao
function getZhiBiaoConfig(zhibiaoName){
  for(var i=0;i<Global.elementArray.length;i++){
    if(Global.elementArray[i].name == zhibiaoName){
      return Global.elementArray[i];
    }
  }
  return null;
}
//生成业务面板
function initControlByName(name){
	for(var i=0;i<Global.elementArray.length;i++){
		if(Global.elementArray[i].name === name){
			Global.currElementObj = Global.elementArray[i];
			break;
		}
	}
  var currElementObj = Global.currElementObj;
	var pluginsHtml = "";
	//指标类型控件
	pluginsHtml += namePlugins.html(Global.elementArray,currElementObj.name,
    currElementObj.zhibiaoArray,currElementObj.zhibiaoCaptionArray,currElementObj.requestTypeArray,currElementObj.panelNames);
     /**干旱分析类型 */
  pluginsHtml += Droughs.html(currElementObj.Droughs);
    /**土壤层次平均 */
    pluginsHtml += HumidityAvgs.html(currElementObj.HumidityAvgs);
    /**土壤类型*/
    pluginsHtml += HumidityTypes.html(currElementObj.HumidityTypes);
	   /**生产类作物类型*/
    pluginsHtml += CropTypes.html(currElementObj.CropTypes);
	//时间控件
	pluginsHtml += dateTime.html(currElementObj.timeTypeArray);
  /*多年同期时间选择*/
	pluginsHtml += yearsSamePeriod.html(currElementObj.timeTypeArray);
	//DayTimeType控件 日类型选择控件(08-08/20-20)
	pluginsHtml += dayTimeType.html(currElementObj.isDayTimeTypeSupportted);
	/*站点类型*/
  pluginsHtml += stationType.html(currElementObj.stationTypeArray);
  /*空间条件*/
  pluginsHtml += spaceCondition.html(currElementObj.spaceType,currElementObj.spatialWayArray);
	/*阈值组件*/
  pluginsHtml += thresholdRange.html(currElementObj.thresholdRange, Global.layName);
  /*积温*/
  pluginsHtml += SteadyJiWen.html();
  /*计算类型*/
	pluginsHtml += calculateType.html(currElementObj.isGroupByDay, currElementObj.calWayArray);
	/*历史统计*/
  pluginsHtml += historyStatic.html(currElementObj.historyStatic);
  /*指标设置*/
  pluginsHtml += indexSetting.html(currElementObj.indexSetting);
   /*干热风指标设置*/
  pluginsHtml += drySetting.html(currElementObj.drySetting);
  

  $("#middleDiv").children('.middle-content').html(pluginsHtml);

  /*渲染业务面板ui，事件处理*/
  renderConditionUi();
  //渲染图列
    colorSelect.init();
  if(currElementObj.isNotTable=="true"||currElementObj.isNotTable==true){
	  $('.content-nav .map-nav').trigger('click');
	  $('.content-nav .table-nav').hide();

  }else{
	  $('.content-nav .table-nav').show();
	  $('.content-nav .table-nav').trigger('click');
  }
  /*生成后默认请求一次*/
  // $('.condition-query').trigger('click');
}

/*渲染查询条件ui，事件处理*/
function renderConditionUi () {

	/*dom更新，ui重新渲染 (组件类型 null为所有，其容器内的)*/
  layForm.render(null, 'middleDiv');

  /*日期选择*/
	dateTime.renderCallback();

  /*多年同期时间选择*/
  yearsSamePeriod.renderCallback();
  /*指标类型切换，重新加载组件模版*/
	namePlugins.renderCallback();
	/*阈值范围勾选*/
  thresholdRange.renderCallback();
  /*选择站点 自定义站*/
	stationType.renderCallback();
	/*历史统计根据选择展示时间选择*/
	historyStatic.renderCallback();
	/*空间统计条件禁用*/
  spaceCondition.renderCallback();
  /*空间统计条件禁用*/
  indexSetting.renderCallback();
drySetting.renderCallback();
  HumidityAvgs.renderCallback();
}

/*请求表格数据*/
function requestData() {
	/*初始化请求模版*/
  Global.postData = new CreateRequestData();

  Global.requestJudge = true;
	/*获取各组件数据*/
	/*历史统计*/
  historyStatic.getData();
	/*值范围*/
  thresholdRange.getData();
	/*站点*/
  stationType.getData();

  SteadyJiWen.getData();

	/*时间，历史同期的时间*/
	var queryTypeValue = $('#selectTypeSelect').val();
	if ( queryTypeValue === 'Spatial' || queryTypeValue === 'Forecast') {
    dateTime.getData();
  } else if ( queryTypeValue === 'History' ) {
    yearsSamePeriod.getData();
  }

  /*日类型*/
  dayTimeType.getData();
	/*指标和类别*/
  namePlugins.getData();
	/*计算值*/
  calculateType.getData();
  /*空间类型和统计*/
  spaceCondition.getData();
  /*指标设置*/
  indexSetting.getData();
  /**干旱类型 */
  Droughs.getData();
    /**土壤层次平均类型 */
    HumidityAvgs.getData();
    /**土壤类型 */
    HumidityTypes.getData();
   /*干热风指标设置*/
  drySetting.getData();
    /*生产类作物类型*/
    CropTypes.getData();

  /*判断请求时间时是否满足条件*/
  if ( Global.requestJudge === false ) return;
  
  /*格点数据请求直接请求DAP*/
  if(Global.currElementObj.isNotTable=="true"||Global.currElementObj.isNotTable==true){
	  gisGraphics.init();
  }else{
	  /*表格数据初始化*/
	  tablePage.init();
  }
  

}


  /*dom初始化事件*/
function initDom () {

  /*查询按钮请求数据*/
  $('#middleDiv').find('.condition-query').click( requestData );

  /*tab，表格，地图 切换*/
  layElement.on('tab(mainContent)', function(data){
    /*切换到地图显示图例框，标题和单位，表格隐藏*/
    var displayDom = $('.map-tool, .gis-title, .gis-product-unit'),
        colorLegend = $('.color-legend-layer').parents('.layui-layer-page');

    if ( data.index === 1 ) {
      displayDom.show();
      colorLegend.show();
    } else {
      displayDom.hide();
      colorLegend.hide();

      /*关闭地图信息弹窗*/
      layLayer.close(Global.mapInfoLayer);
    }
  });

  /*Gis图形产品，渲染方案点击事件*/
  $('#gisGraphics').find('.render-plan').click(function () {
    colorSelect.openLayer();
  });


  /*右上导航*/
  layElement.on('nav(rightNav)', function(e){
    switch ($(e).attr('data-nav')) {
      /*页面导航主题色*/
      case 'themeChange':
        layLayer.open({
          title: '主题色方案',
          type: 1,
          btn: false,
          closeBtn: false,
          shadeClose: true,
          resize: false,
          move: false,
          area: ['300px', 'calc(100% - 60px)'],
          offset: 'rb',
          anim: 2,
          content: $('#themeColor')
        });
        break;
    }
  });

  /*主题色切换*/
  $('.theme-color .item').click(function () {
    /*当前返回*/
    if($(this).hasClass('active')) return;
    /*激活*/
    $(this).addClass('active').siblings().removeClass('active');

    /*主题色*/
    var theme = 'layui-bg-blue layui-bg-black layui-bg-cyan bg-white bg-blue-dark bg-cyan-dark bg-black-dark bg-white-dark',
        topNav = $('#navDiv'),
        leftNav = $('.left-content');

    /*当前主题*/
    var currentTheme = $(this).attr('data-theme');

    /*左侧（白色图片反色处理）*/
    var prevLeftColor = Boolean(leftNav.parent().hasClass('theme-bg-white')),
        currentColor = Boolean(['white', 'blue-white'].indexOf(currentTheme ) === -1);
    if ( prevLeftColor === currentColor ) { navImg(); }

    leftNav.parent().removeClass('theme-bg-white');
    topNav.parent().removeClass('theme-bg-white');


    switch (currentTheme) {
      case 'black':
        topNav.removeClass(theme).addClass('layui-bg-black');
        leftNav.removeClass(theme).addClass('layui-bg-cyan')
          .siblings('.left-title').removeClass(theme).addClass('bg-cyan-dark');
        break;
      case 'blue':
        topNav.removeClass(theme).addClass('layui-bg-blue');
        leftNav.removeClass(theme).addClass('layui-bg-blue')
          .siblings('.left-title').removeClass(theme).addClass('bg-blue-dark');
        break;
      case 'blue-black':
        topNav.removeClass(theme).addClass('layui-bg-blue');
        leftNav.removeClass(theme).addClass('layui-bg-black')
          .siblings('.left-title').removeClass(theme).addClass('bg-black-dark');
        break;
      case 'blue-white':
        topNav.removeClass(theme).addClass('layui-bg-blue');
        leftNav.removeClass(theme).addClass('bg-white')
          .siblings('.left-title').removeClass(theme).addClass('bg-white-dark');

        leftNav.parent().addClass('theme-bg-white');
        break;
      case 'white':
        topNav.removeClass(theme).addClass('bg-white');
        leftNav.removeClass(theme).addClass('bg-white')
          .siblings('.left-title').removeClass(theme).addClass('bg-white-dark');

        topNav.parent().addClass('theme-bg-white');
        leftNav.parent().addClass('theme-bg-white');
        break;
    }


    function navImg() {
      $('#leftDiv').find('img').each(function () {
        var _this = this;
        complementaryColor($(this).prop('src'), function (img) {
          $(_this).prop('src', img);
        });
      });
    }

  });

    /*默认主题色*/
    setTimeout(function () {
      $('#themeColor').find('li.item[data-theme="blue-white"]').trigger('click');
    }, 0)
  


  //当前区域选择
  $("#home").on( "click", function() {
    areaPanelOpt.init();
    $(".areaChangePanel").show();
  });

  $("#logoimg").on("click",function(){
    cropSelectPanel.init();
    if($(".cropSelectPanel").css("display") == "none"){
      $(".cropSelectPanel").show();
    }else{
      $(".cropSelectPanel").hide();
    }
  })
}